<?php
/**
 * Needed :
 * $building_id = the building id
 * $model = floor model
 */
        $gridId = $building_id . "fg";
        
        //Dialog box - defined in index
        //$this->renderPartial("_formDialog");

        //Confirmation dialog - defined in index
        //$this->renderPartial("_confirmationModalDialog");

	//CGridView
        $jsDelFunction = '
            openConfirmationModalDialog(
                \"Are you sure you want to delete <b>$data->floor_number</b>?\",
                function(){
                    var url = \"'.$this->createUrl("floor/delete", array("id" => "xidx")).'\"
                    \$.getJSON(
                    url.replace(\"xidx\", \"$data->id\"),
                    function(data) {
                        if(data.errId) {

                        } else {
                            $.fn.yiiGridView.update(\"'.$gridId.'\");
                            closeConfirmationModalDialog();
                            MAP.refresh();
                        }
                    }
                );}
            )
        ';
	$this->widget('zii.widgets.grid.CGridView', array(
		'id'=>$gridId,
		'dataProvider'=>$model->search(),
		'columns'=>array(
                    //name button
                    array(
                        'header' => $model->getLabelName('floor_number'),
                        'value' => 'CHtml::link($data->floor_number, "#map", array("onclick" => "MAP.goto(".$data->id.", 0, 1);"))',
                        'type' => 'raw'
                    ),
                    array(
                        'value' => 'CHtml::button("Edit", array("onclick" => "floor_openForUpdate($data->id, $data->floor_number, \"'.$gridId.'\");")) . " " . CHtml::button("Delete", array("onclick" => "'.$jsDelFunction.'")) ',
                        'type' => 'raw',
                        'htmlOptions'=>array('width' => '150'),
                    ),
		),
	));

	//add new room type
        echo CHtml::button('Tambahkan Lantai', array(
           'onclick'=>'floor_openForCreate("'.$building_id.'","'.$gridId.'"); return false;',
        ));
?>